home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / site-packages / impacket / ImpactDecoder.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2006-06-30  |  6KB  |  183 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import ImpactPacket
  5.  
  6. class Decoder:
  7.     
  8.     def decode(self, aBuffer):
  9.         pass
  10.  
  11.  
  12.  
  13. class EthDecoder(Decoder):
  14.     
  15.     def __init__(self):
  16.         pass
  17.  
  18.     
  19.     def decode(self, aBuffer):
  20.         e = ImpactPacket.Ethernet(aBuffer)
  21.         off = e.get_header_size()
  22.         if e.get_ether_type() == ImpactPacket.IP.ethertype:
  23.             self.ip_decoder = IPDecoder()
  24.             packet = self.ip_decoder.decode(aBuffer[off:])
  25.         elif e.get_ether_type() == ImpactPacket.ARP.ethertype:
  26.             self.arp_decoder = ARPDecoder()
  27.             packet = self.arp_decoder.decode(aBuffer[off:])
  28.         else:
  29.             self.data_decoder = DataDecoder()
  30.             packet = self.data_decoder.decode(aBuffer[off:])
  31.         e.contains(packet)
  32.         return e
  33.  
  34.  
  35.  
  36. class LinuxSLLDecoder(Decoder):
  37.     
  38.     def __init__(self):
  39.         pass
  40.  
  41.     
  42.     def decode(self, aBuffer):
  43.         e = ImpactPacket.LinuxSLL(aBuffer)
  44.         off = 16
  45.         if e.get_ether_type() == ImpactPacket.IP.ethertype:
  46.             self.ip_decoder = IPDecoder()
  47.             packet = self.ip_decoder.decode(aBuffer[off:])
  48.         elif e.get_ether_type() == ImpactPacket.ARP.ethertype:
  49.             self.arp_decoder = ARPDecoder()
  50.             packet = self.arp_decoder.decode(aBuffer[off:])
  51.         else:
  52.             self.data_decoder = DataDecoder()
  53.             packet = self.data_decoder.decode(aBuffer[off:])
  54.         e.contains(packet)
  55.         return e
  56.  
  57.  
  58.  
  59. class IPDecoder(Decoder):
  60.     
  61.     def __init__(self):
  62.         pass
  63.  
  64.     
  65.     def decode(self, aBuffer):
  66.         i = ImpactPacket.IP(aBuffer)
  67.         off = i.get_header_size()
  68.         if i.get_ip_p() == ImpactPacket.UDP.protocol:
  69.             self.udp_decoder = UDPDecoder()
  70.             packet = self.udp_decoder.decode(aBuffer[off:])
  71.         elif i.get_ip_p() == ImpactPacket.TCP.protocol:
  72.             self.tcp_decoder = TCPDecoder()
  73.             packet = self.tcp_decoder.decode(aBuffer[off:])
  74.         elif i.get_ip_p() == ImpactPacket.ICMP.protocol:
  75.             self.icmp_decoder = ICMPDecoder()
  76.             packet = self.icmp_decoder.decode(aBuffer[off:])
  77.         else:
  78.             self.data_decoder = DataDecoder()
  79.             packet = self.data_decoder.decode(aBuffer[off:])
  80.         i.contains(packet)
  81.         return i
  82.  
  83.  
  84.  
  85. class ARPDecoder(Decoder):
  86.     
  87.     def __init__(self):
  88.         pass
  89.  
  90.     
  91.     def decode(self, aBuffer):
  92.         arp = ImpactPacket.ARP(aBuffer)
  93.         off = arp.get_header_size()
  94.         self.data_decoder = DataDecoder()
  95.         packet = self.data_decoder.decode(aBuffer[off:])
  96.         arp.contains(packet)
  97.         return arp
  98.  
  99.  
  100.  
  101. class UDPDecoder(Decoder):
  102.     
  103.     def __init__(self):
  104.         pass
  105.  
  106.     
  107.     def decode(self, aBuffer):
  108.         u = ImpactPacket.UDP(aBuffer)
  109.         off = u.get_header_size()
  110.         self.data_decoder = DataDecoder()
  111.         packet = self.data_decoder.decode(aBuffer[off:])
  112.         u.contains(packet)
  113.         return u
  114.  
  115.  
  116.  
  117. class TCPDecoder(Decoder):
  118.     
  119.     def __init__(self):
  120.         pass
  121.  
  122.     
  123.     def decode(self, aBuffer):
  124.         t = ImpactPacket.TCP(aBuffer)
  125.         off = t.get_header_size()
  126.         self.data_decoder = DataDecoder()
  127.         packet = self.data_decoder.decode(aBuffer[off:])
  128.         t.contains(packet)
  129.         return t
  130.  
  131.  
  132.  
  133. class IPDecoderForICMP(Decoder):
  134.     '''This class was added to parse the IP header of ICMP unreachables packets
  135.     If you use the "standard" IPDecoder, it might crash (see bug #4870) ImpactPacket.py
  136.     because the TCP header inside the IP header is incomplete'''
  137.     
  138.     def __init__(self):
  139.         pass
  140.  
  141.     
  142.     def decode(self, aBuffer):
  143.         i = ImpactPacket.IP(aBuffer)
  144.         off = i.get_header_size()
  145.         if i.get_ip_p() == ImpactPacket.UDP.protocol:
  146.             self.udp_decoder = UDPDecoder()
  147.             packet = self.udp_decoder.decode(aBuffer[off:])
  148.         else:
  149.             self.data_decoder = DataDecoder()
  150.             packet = self.data_decoder.decode(aBuffer[off:])
  151.         i.contains(packet)
  152.         return i
  153.  
  154.  
  155.  
  156. class ICMPDecoder(Decoder):
  157.     
  158.     def __init__(self):
  159.         pass
  160.  
  161.     
  162.     def decode(self, aBuffer):
  163.         ic = ImpactPacket.ICMP(aBuffer)
  164.         off = ic.get_header_size()
  165.         if ic.get_icmp_type() == ImpactPacket.ICMP.ICMP_UNREACH:
  166.             self.ip_decoder = IPDecoderForICMP()
  167.             packet = self.ip_decoder.decode(aBuffer[off:])
  168.         else:
  169.             self.data_decoder = DataDecoder()
  170.             packet = self.data_decoder.decode(aBuffer[off:])
  171.         ic.contains(packet)
  172.         return ic
  173.  
  174.  
  175.  
  176. class DataDecoder(Decoder):
  177.     
  178.     def decode(self, aBuffer):
  179.         d = ImpactPacket.Data(aBuffer)
  180.         return d
  181.  
  182.  
  183.